package leo.manager
{
	import flash.net.LocalConnection;
	
	import leo.data.GameModel;
	import leo.game.display.BaseMonster;
	import leo.game.ui.UIBottom;
	import leo.game.ui.UILevel;
	import leo.game.ui.UILose;
	import leo.game.ui.UIMap;
	import leo.game.ui.UITop;
	import leo.game.ui.UIWin;

	public class WinOrLoseManager
	{
		private static var _instance :WinOrLoseManager = null;
		
		//强制垃圾回收使用的对象
		private var conn1 :LocalConnection;
		private var conn2 :LocalConnection;
		public function WinOrLoseManager()
		{
		}
		/**
		 * 赢 
		 */		
		public function win():void
		{
			UIWin.instance.showUIWin(1000,400,300);

			GameModel.instance.clearData();
			UIBottom.instance.resetBTN();
//			UIBottom.instance.showBottom(1000,0,650);
//			UITop.instance.showUITop(1000,0,-50);
			MonsterManager.instance.resetMonsterManager();
			UIMap.instance.cancel();
			UIMap.instance.removeTowerAttRange();
		}
		/**
		 * 输
		 */		
		public function lose():void
		{
			UILose.instance.showUILose(1000,300,250);
			GameModel.instance.clearData();
			UIBottom.instance.resetBTN();
//			UIBottom.instance.showBottom(1000,0,650);
//			UITop.instance.showUITop(1000,0,-50);
			MonsterManager.instance.resetMonsterManager();
			UIMap.instance.cancel();
			UIMap.instance.removeTowerAttRange();
		}


		public static function get instance():WinOrLoseManager
		{
			if(_instance == null)
			{
				_instance = new WinOrLoseManager();
			}
			return _instance;
		}
		
		
		/**
		 * 强制垃圾回收
		 */		
		public function doClearance( ) : void 
		{
			try
			{
				conn1 = new LocalConnection();
				conn1.connect(" garbage collection 1");
				conn2 = new LocalConnection();
				conn2.connect(" garbage collection 1");
			}catch(e :*){}
			finally
			{
				conn1 = null;
				conn2 = null;
			}
			trace("clear");
		}

	}
}